package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysRobotType;
import com.ruoyi.system.service.ISysRobotTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 机器人类型Controller
 * 
 * @author ruoyi
 * @date 2023-12-26
 */
@RestController
@Api("机器人类型管理")
@RequestMapping("/system/type")
public class SysRobotTypeController extends BaseController
{
    @Autowired
    private ISysRobotTypeService sysRobotTypeService;

    /**
     * 查询机器人类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:type:list')")
    @GetMapping("/list")
    @ApiOperation("查询机器人类型列表")
    public TableDataInfo list(SysRobotType sysRobotType)
    {
        startPage();
        List<SysRobotType> list = sysRobotTypeService.selectSysRobotTypeList(sysRobotType);
        return getDataTable(list);
    }

    /**
     * 导出机器人类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:type:export')")
    @Log(title = "机器人类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出机器人类型列表")
    public void export(HttpServletResponse response, SysRobotType sysRobotType)
    {
        List<SysRobotType> list = sysRobotTypeService.selectSysRobotTypeList(sysRobotType);
        ExcelUtil<SysRobotType> util = new ExcelUtil<SysRobotType>(SysRobotType.class);
        util.exportExcel(response, list, "机器人类型数据");
    }

    /**
     * 获取机器人类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:type:query')")
    @GetMapping(value = "/{typeId}")
    @ApiOperation("获取机器人类型详细信息")
    public AjaxResult getInfo(@PathVariable("typeId") Long typeId)
    {
        return success(sysRobotTypeService.selectSysRobotTypeByTypeId(typeId));
    }

    /**
     * 新增机器人类型
     */
    @PreAuthorize("@ss.hasPermi('system:type:add')")
    @Log(title = "机器人类型", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增机器人类型")
    public AjaxResult add(@RequestBody SysRobotType sysRobotType)
    {
        return toAjax(sysRobotTypeService.insertSysRobotType(sysRobotType));
    }

    /**
     * 修改机器人类型
     */
    @PreAuthorize("@ss.hasPermi('system:type:edit')")
    @Log(title = "机器人类型", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改机器人类型")
    public AjaxResult edit(@RequestBody SysRobotType sysRobotType)
    {
        return toAjax(sysRobotTypeService.updateSysRobotType(sysRobotType));
    }

    /**
     * 删除机器人类型
     */
    @PreAuthorize("@ss.hasPermi('system:type:remove')")
    @Log(title = "机器人类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{typeIds}")
    @ApiOperation("删除机器人类型")
    public AjaxResult remove(@PathVariable Long[] typeIds)
    {
        return toAjax(sysRobotTypeService.deleteSysRobotTypeByTypeIds(typeIds));
    }
}
